<template>
  <div style="height:100%">
    <Title title="流调数据统计" @click-more='handleClickMore'>
      <AccRadio v-model="currentCheck" :options='options'></AccRadio>
    </Title>
    <AccBar :echartData="echartData"></AccBar>
  </div>
</template>

<script>
import { getFlowModulation } from '@/views/children/antiepidemic/js/statisticalAnalysis'
import Vue from 'vue'
import { USER_INFO } from '@/store/mutation-types'
import Title from '../Title'
import AccRadio from '@/components/common/AccRadio'
import AccBar from '../common/AccBar.vue'
export default {
  // eslint-disable-next-line vue/no-unused-components
  components: { Title, AccRadio, AccBar },
  data () {
    return {
      currentCheck: '学生',
      options: [ '学生', '教师', '全部' ],
      echartData: {
        label: [],
        value: []
      }
    }
  },
  watch: {
    currentCheck: {
      handler () {
        this.getData()
      },
      immediate: true
    }
  },
  methods: {
    handleClickMore () {
      this.$router.push({ path: '/antiepidemic/health' })
    },
    getData () {
      let flagJson = {
        '学生': '1',
        '教师': '2',
        '全部': '0'
      }
      getFlowModulation({
        tenantNo: Vue.ls.get(USER_INFO).tenantNo,
        flag: flagJson[this.currentCheck] || ''
      }).then(res => {
        const { code, data } = res
        if (code === 0) {
          this.echartData.label = data.modulationJson.xData
          this.echartData.value = data.modulationJson.yData
        }
      })
    }
  }
}
</script>

<style>

</style>
